GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 84a66e...a6029b )
by Benjamin
01:37
created

stateGetter.js ➔ stateGetter   C

Complexity

Conditions 25
Paths 15

Size

Total Lines 64

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 25
c 2
b 0
f 2
nc 15
dl 0
loc 64
rs 5.8539
nop 4

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like stateGetter.js ➔ stateGetter often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
/*
2
* central function to retrieve state from reducer
3
* used inside of mapStateToProps by grid and other plugins
4
* @returns {object} state
5
6
* will not return immutable object, only plain JS object
7
8
* if a dynamic reducerKey is passed, it will favor that key
9
* over the build in grid keys
10
11
*/
12
13
export const stateGetter = (state, props, key, entry) => {
14
15
    if (props
16
        && props.reducerKeys
17
        && Object.keys(props.reducerKeys).length > 0
18
        && props.reducerKeys[key]) {
19
20
        const dynamicKey = props.reducerKeys[key];
21
        const dynamicState = get(state, dynamicKey, entry);
22
23
        return dynamicState && dynamicState.toJS
24
            ? dynamicState.toJS()
25
            : dynamicState;
26
    }
27
28
    const val = get(state, key, entry);
29
30
    if (val) {
31
        return val.toJS ? val.toJS() : val;
32
    }
33
34
    return null;
35
};
36
37
export const get = (state, key, entry) => state
38
    && state[key]
39
    && state[key].get
40
    && state[key].get(entry)
41
        ? state[key].get(entry)
42
        : null;
43